/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.wish
 * WishController.java
 * 创建人:小胡
 * 时间：2017年01月17日 09:47:42
 *
 */
package com.tz.web.wish;

import com.tz.auth.AuthPassport;
import com.tz.bean.TzParams;
import com.tz.bean.Wish;
import com.tz.service.wish.IWishService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * 意见反馈管理web
 * WishController
 * 创建人:小胡
 * 时间：2017年01月17日 09:47:42
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/wish")
public class WishController {
	
	@Resource
	private IWishService wishService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/list")
	public String list(TzParams params,Model model){
		model.addAttribute("params",params);
		return "wish/list";
	}

    /*模板页面*/
	@RequestMapping("/template")
	public String template(TzParams params ,Model model){
		model.addAttribute("datas", wishService.findWishs(params));
		model.addAttribute("itemCount", wishService.count(params));
		return "wish/template";
	}

	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		wishService.delete(params);
		return "success";
	}
	@RequestMapping("/add")
    public String add(TzParams params){
		return "wish/add";
   }


	@RequestMapping(value = "/edit/{id}" ,method = RequestMethod.GET)
    public String edit(@PathVariable("id") Integer id , Model model){
		HashMap<String ,Object> wish = wishService.getWish(id);
		model.addAttribute("wish",wish);
		return "wish/edit";
	}

	@ResponseBody
	@RequestMapping(value="/update")
	public String update(Wish wish){
		wishService.update(wish);
		return "success";
	}



}
